package try_java;

import java.util.Arrays;

public class ArrayTest {
    public static void main(String [] args) {
        int [] a = new int [5];
        for (int i = 0; i < a.length; i++) {
            a[i]= i + 1; 
        }
        System.out.println(Arrays.toString(a));
        int [] b = {22, 33, 44, 55, 66};
        System.out.println(Arrays.toString(b));
        a = new int [] {4, 6, 7};
        System.out.println(Arrays.toString(a));
        b = a;
        System.out.println(Arrays.toString(b));
        b[1] = 20;
        System.out.println(Arrays.toString(a));
        a = Arrays.copyOf(b, b.length * 2);
        System.out.println(Arrays.toString(a));
        System.out.println(Arrays.toString(b));
        a[0] = 100;
        System.out.println(Arrays.toString(a));
        System.out.println(Arrays.toString(b));
        b = new int [] {44, 99, 22, 11, 66};
        System.out.println(Arrays.toString(b));
        Arrays.sort(b);
        for (int r : b) {
            System.out.println(r);
        }
//        Scanner in = new Scanner(System.in);
//        System.out.println("Input the Array Length");
//        int n = in.nextInt();
//        System.out.println("Input the Largest Number you want");
//        int k = in.nextInt();
//        System.out.printf("n = %d, k = %d\n", n, k);
//        System.out.println("Input a line");
//        in.nextLine();
//        String s = in.nextLine();
//        System.out.println("input line is " + s);
        int index = Arrays.binarySearch(b, 66);
        System.out.printf("the index is %d\n", index);
    }
}
